package com.server.questionbank.snframe.util.FileUtil.policy;

import org.apache.commons.lang3.StringUtils;

/**
 * 抽象存储桶策略
 */
public abstract class AbstractPolicy implements BucketPolicy {
    
    @Override
    public String generatePolicy(String bucketName) {
        validate(bucketName);
        return doBuildPolicy(bucketName);
    }
    
    /**
     * 构建具体策略JSON
     */
    protected abstract String doBuildPolicy(String bucketName);
    
    @Override
    public void validate(String bucketName) {
        if (StringUtils.isEmpty(bucketName)) {
            throw new IllegalArgumentException("Bucket name cannot be empty");
        }
    }
} 